Skip to content

fix(install): reject archive with path traversal before extraction (#1250)#1368

Merged
aeppling merged 1 commit into
rtk-ai:developfrom
ousamabenyounes:fix/issue-1250
May 13, 2026
Merged

fix(install): reject archive with path traversal before extraction (#1250)#1368
aeppling merged 1 commit into
rtk-ai:developfrom
ousamabenyounes:fix/issue-1250

Conversation

@ousamabenyounes
Copy link
Copy Markdown
Contributor

@ousamabenyounes ousamabenyounes commented Apr 17, 2026

Summary

Fixes #1250 — CWE-22 path traversal in install.sh.

  • install.sh now lists archive contents with tar -tzf before extraction and rejects any entry that starts with / or contains a .. path component.
  • The check is POSIX-compliant and adds negligible overhead (the RTK release tarball ships a single binary).
  • Covered by a new scripts/test-install.sh that exercises one safe archive and four crafted malicious archives (leading ../, absolute path, mid-path .., trailing ..), plus a regression guard that fails if the check is removed from install.sh.

Test plan

  • bash scripts/test-install.sh — all 6 cases pass (1 safe, 4 malicious rejected, 1 regression guard).
  • cargo fmt --all --check && cargo clippy --all-targets && cargo test — 1590 pass / 0 fail / 6 ignored (unchanged from baseline).
  • Manual sanity: tar -tzf pipeline verified against hand-crafted tarballs containing ../etc/evil, /tmp/abs, rtk/../../../etc/x, rtk/.. — all correctly rejected; rtk, ./rtk, ..hidden, rtk/subdir/bin correctly accepted.

Vibe Coded by Ousama Ben Younes
Developed With Ora Studio (Claude Code)

…tk-ai#1250)

The installer previously ran `tar -xzf` on the downloaded archive with no
pre-extraction verification. A malicious mirror could ship a tarball with
`../` components or absolute paths and write files anywhere on the user's
filesystem (CWE-22).

Add a pre-extraction check that lists archive contents with `tar -tzf`
and rejects any entry whose name starts with `/` or contains a `..` path
component. The check is POSIX-compliant and adds negligible overhead for
the single-binary RTK release tarball.

Covered by scripts/test-install.sh, which exercises one safe archive
and four crafted malicious archives (leading `..`, absolute path,
mid-path `..`, trailing `..`) plus a regression guard that ensures the
check remains in install.sh.

Co-Authored-By: Claude <noreply@anthropic.com>
@pszymkowiak pszymkowiak added bug Something isn't working effort-small Quelques heures, 1 fichier labels Apr 17, 2026
@pszymkowiak
Copy link
Copy Markdown
Collaborator

[w] wshm · Automated triage by AI

📊 Automated PR Analysis

🐛 Type bug-fix
🟢 Risk low

Summary

Adds a path traversal guard to install.sh that lists archive contents with tar -tzf before extraction and rejects any entry containing absolute paths or .. components (CWE-22). Includes a comprehensive test script covering safe and malicious archive scenarios plus a regression guard.

Review Checklist

  • Tests present
  • Breaking change
  • Docs updated

Linked issues: #1250


Analyzed automatically by wshm · This is an automated analysis, not a human review.

Copy link
Copy Markdown
Collaborator

@pszymkowiak pszymkowiak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review ✅

Testé en live avec bash scripts/test-install.sh — 6/6 cas passent :

  • archive safe acceptée ✅
  • 4 archives malveillantes rejetées (leading ../, absolute path, mid-path ..., trailing /..) ✅
  • regression guard présent ✅

Le fix tar -tzf avant extraction est POSIX-compatible et overhead négligeable. Correction critique pour les utilisateurs curl | sh.

LGTM

@aeppling
Copy link
Copy Markdown
Contributor

Hey @ousamabenyounes , thanks for your patience.

LGTM

@aeppling aeppling merged commit e827184 into rtk-ai:develop May 13, 2026
12 checks passed
@aeppling aeppling mentioned this pull request May 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working effort-small Quelques heures, 1 fichier

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Path traversal risk in install.sh tar extraction

3 participants